package main

import (
	"fmt"
)

func main() {
	ch := make(chan int, 0)
	//len(ch)缓冲区中数据的个数，cap（ch）缓冲区大小，或者容量
	//fmt.Println("len(ch)=%d,cap(ch)=%d", len(ch), cap(ch))

	go func (){
		defer fmt.Println("zi结束")
		for i:=0;1<5 ;i++ {

			ch<-i
			fmt.Println("zi。。goroutine...len(ch)=%d,cap(ch)=%d", len(ch), cap(ch))

			//time.Sleep(time.Second)
		}
	}()

	for i:=0;i<5;i++{
		num:=<-ch
		fmt.Println(num)
		//time.Sleep(time.Second)
	}
}
